<html>
<head><meta charset="utf-8"><title>Implementation question regarding rust-analyzer#389 - &quot;ge... · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html">Implementation question regarding rust-analyzer#389 - &quot;ge...</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="247103823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247103823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Gonzalez <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247103823">(Jul 25 2021 at 02:19)</a>:</h4>
<p>Hello, guys! I'm new here so I don't really know how zulip works. Sorry if I am not sending the message to the right channel.</p>
<p>So, I am working on <a href="https://github.com/rust-analyzer/rust-analyzer/issues/389">https://github.com/rust-analyzer/rust-analyzer/issues/389</a> and I have some questions regarding that issue. As the issue says, textDocument/hover speaks about a position, not ranges, so we would have to change it somehow to include the range. But the example given is about extending the server response of CodeActions, which I think is not the same. So, I have been trying to change the position param to a range, but that involves changing the client typescript code, so I am not sure if that is the way to go or if I'm misinterpreting something.</p>
<p>Could someone give me any pointers on this? Should I be changing the code in the client? Thanks!</p>



<a name="247104190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247104190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247104190">(Jul 25 2021 at 02:30)</a>:</h4>
<p>It looks like <a href="https://github.com/rust-analyzer/rust-analyzer/issues/389#issuecomment-849448988">the advice given by matklad in that issue</a> is to extend HoverParams to be an enum of _either_ <code>Position</code> or <code>Range</code>; presumably, for back-compat, it would be nice if the TypeScript side would understand a default of <code>Position</code> if it doesn't look like the enum type, but I'm pretty sure that's unnecessary with RA's update model.</p>
<p>To clarify: Yes, I believe you'll have to change code in both the typescript and the rust portions.</p>



<a name="247106621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247106621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Gonzalez <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247106621">(Jul 25 2021 at 03:46)</a>:</h4>
<p>Yeah, I thought of making it an enum, but assumed that I could make it work since a Position is a Range of length 0. But I think that using an enum would be clearer. Thank you!</p>
<p>In any case, the main problem I have is that I am not sure of how to extend the params in the typescript side <span aria-label="sweat" class="emoji emoji-1f613" role="img" title="sweat">:sweat:</span> </p>
<p>Halp!</p>



<a name="247118264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247118264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247118264">(Jul 25 2021 at 09:42)</a>:</h4>
<p>I believe you wanna touch this part on the typescript side <a href="https://github.com/rust-analyzer/rust-analyzer/blob/2fe586a8a781f22f4e5a82037ed459fe28e87f8f/editors/code/src/client.ts#L58-L74">https://github.com/rust-analyzer/rust-analyzer/blob/2fe586a8a781f22f4e5a82037ed459fe28e87f8f/editors/code/src/client.ts#L58-L74</a></p>



<a name="247118273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247118273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247118273">(Jul 25 2021 at 09:43)</a>:</h4>
<p>(deleted)</p>



<a name="247258297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247258297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Gonzalez <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247258297">(Jul 26 2021 at 20:37)</a>:</h4>
<p>Hey guys! I have another question here. How should I go about adding the server/client capability here <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span>? I can't seem to figure it out.</p>



<a name="247258409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247258409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Gonzalez <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247258409">(Jul 26 2021 at 20:38)</a>:</h4>
<p>We have <code>hover_provider: Some(HoverProviderCapability::Simple(true))</code>, but I am not sure about how should I extend it.</p>



<a name="247259600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247259600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Gonzalez <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247259600">(Jul 26 2021 at 20:47)</a>:</h4>
<p>I think that the requirement is supporting hovers and r-a does support them :D</p>



<a name="247269674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247269674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247269674">(Jul 26 2021 at 22:02)</a>:</h4>
<p>The capabilities have an <code>experimental</code> field which is just a json blob, thats where you should put something</p>



<a name="247269711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247269711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247269711">(Jul 26 2021 at 22:02)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">        </span><span class="n">experimental</span>: <span class="nb">Some</span><span class="p">(</span><span class="n">json</span><span class="o">!</span><span class="p">({</span><span class="w"></span>
<span class="w">            </span><span class="s">"joinLines"</span>: <span class="nc">true</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="s">"ssr"</span>: <span class="nc">true</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="s">"onEnter"</span>: <span class="nc">true</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="s">"parentModule"</span>: <span class="nc">true</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="s">"runnables"</span>: <span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="s">"kinds"</span>: <span class="p">[</span><span class="w"> </span><span class="s">"cargo"</span><span class="w"> </span><span class="p">],</span><span class="w"></span>
<span class="w">            </span><span class="p">},</span><span class="w"></span>
<span class="w">            </span><span class="s">"workspaceSymbolScopeKindFiltering"</span>: <span class="nc">true</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="p">})),</span><span class="w"></span>
</code></pre></div>
<p><a href="https://github.com/Veykril/rust-analyzer/blob/3fab50019c0e19fbd06891c83038b1593ba7901a\crates\rust-analyzer\src\caps.rs#L115-L124">https://github.com/Veykril/rust-analyzer/blob/3fab50019c0e19fbd06891c83038b1593ba7901a\crates\rust-analyzer\src\caps.rs#L115-L124</a></p>



<a name="247269767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247269767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247269767">(Jul 26 2021 at 22:03)</a>:</h4>
<p>client caps are here -&gt; <a href="https://github.com/Veykril/rust-analyzer/blob/3fab50019c0e19fbd06891c83038b1593ba7901a\editors\code\src\client.ts#L162-L175">https://github.com/Veykril/rust-analyzer/blob/3fab50019c0e19fbd06891c83038b1593ba7901a\editors\code\src\client.ts#L162-L175</a></p>



<a name="247271925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247271925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Gonzalez <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247271925">(Jul 26 2021 at 22:26)</a>:</h4>
<p><span class="user-mention" data-user-id="300586">@Lukas Wirth</span>  Thanks man, you are so helpful <span aria-label="pray" class="emoji emoji-1f64f" role="img" title="pray">:pray:</span> </p>
<p>But I don't get it, why do we need to specify this? <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> And since we do, shouldn't it affect the code somehow? That is, shouldn't I fall back to the old behavior if the capability is false or something similar? </p>
<p>Sorry if I am being dumb <span aria-label="disappointed" class="emoji emoji-1f61e" role="img" title="disappointed">:disappointed:</span></p>



<a name="247272014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247272014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247272014">(Jul 26 2021 at 22:27)</a>:</h4>
<p>that I can't tell you either, I'm not familiar with the capabilities part of the protocol</p>



<a name="247300109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Implementation%20question%20regarding%20rust-analyzer%23389%20-%20%22ge.../near/247300109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Implementation.20question.20regarding.20rust-analyzer.23389.20-.20.22ge.2E.2E.2E.html#247300109">(Jul 27 2021 at 06:59)</a>:</h4>
<p>you need to specify it so that clients know they can send a range in the hover request</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>